#include "WordAnalyzer.h"
#include <stdio.h>
//当前yylex()由flex根据文件cc.l产生：
extern int yylex(void);
extern void yyset_in(FILE*);
extern void yyset_out(FILE*);
extern int yylineno;
extern int yyleng;
extern char* yytext;


extern FILE *yyin;
extern FILE *yyout;


WordAnalyzer::WordAnalyzer(const std::string &srcFileName):
	srcFile(srcFileName.c_str()), tokenType(0), lineNumber(0), columnNumber(0)
{
	
	yyin = fopen(srcFileName.c_str(), "r");	
}
WordAnalyzer::~WordAnalyzer()
{
	if(yyin) fclose(yyin);
}
int WordAnalyzer::getToken(void)
{
	tokenType = yylex();
	tokenName = yytext;
	lineNumber = yylineno;
	//columnNumber = ?
	return tokenType;
}
